package cn.tedu.oopstatic;

import org.junit.jupiter.api.Test;

/*
本类用来测试静态的调用关系
alt +7查看结构
 */
public class TestStatic2 {
@Test
    public void t(){
    Teacher.sleep();
}

}

class Teacher {
    String name;
    static int age;

    public void test() {
        /*普通资源可以调用静态资源*/
        System.out.println(age);
        eat();

        System.out.println("正在授课");
    }

    public void teach() {
        System.out.println("老师机");
    }

    public static void eat() {
        /*2.静态资源不可以调用非静态资源
         * 静态资源可以调用静态资源*/
        //System.out.println(name);//编译时异常：Non-static field 'name' cannot be referenced from a static context
        System.out.println("你真能吃");
    }

    public static void sleep() {
        System.out.println("累了困了喝乐虎");
        System.out.println(age);
        eat();

    }
}

